
package com.example.administrator.jinritoutiao.activity;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.example.administrator.jinritoutiao.R;
import com.example.administrator.jinritoutiao.fragment.FragmentGuide;
import com.example.administrator.jinritoutiao.fragment.FragmentGuide2;

public class GuideAvtivity extends FragmentActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_guide_avtivity);
        ViewPager vp = (ViewPager) findViewById(R.id.vp_guide);
        vp.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
            @Override
            public Fragment getItem(int position) {
                Fragment fragment = null;
                switch (position){
                    case 0:
                        fragment = new FragmentGuide();
                        Bundle bundle = new Bundle();
                        bundle.putInt("pic",R.drawable.z2);
                        fragment.setArguments(bundle);
                        break;
                    case 1:
                        fragment = new FragmentGuide2();

                        break;
                }
                return fragment;
            }

            @Override
            public int getCount() {
                return 2;
            }
        });
    }
}
